
package pl.edu.agh.mgr.hotel.ws.client;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;


/**
 * <p>Java class for serviceDescription complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="serviceDescription">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="address" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="city" type="{http://ws.hotel.mgr.agh.edu.pl/}city" minOccurs="0"/>
 *         &lt;element name="country" type="{http://ws.hotel.mgr.agh.edu.pl/}country" minOccurs="0"/>
 *         &lt;element name="dataLevel" type="{http://www.w3.org/2001/XMLSchema}int"/>
 *         &lt;element name="hotelType" type="{http://ws.hotel.mgr.agh.edu.pl/}hotelType" minOccurs="0"/>
 *         &lt;element name="id" type="{http://www.w3.org/2001/XMLSchema}long"/>
 *         &lt;element name="lastModifiedDate" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
 *         &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="province" type="{http://ws.hotel.mgr.agh.edu.pl/}province" minOccurs="0"/>
 *         &lt;element name="roomTypes" type="{http://ws.hotel.mgr.agh.edu.pl/}roomType" maxOccurs="unbounded" minOccurs="0"/>
 *         &lt;element name="street" type="{http://ws.hotel.mgr.agh.edu.pl/}street" minOccurs="0"/>
 *         &lt;element name="wsAddress" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *         &lt;element name="wsName" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "serviceDescription", propOrder = {
    "address",
    "city",
    "country",
    "dataLevel",
    "hotelType",
    "id",
    "lastModifiedDate",
    "name",
    "province",
    "roomTypes",
    "street",
    "wsAddress",
    "wsName"
})
public class ServiceDescription implements Comparable<ServiceDescription> {

    protected String address;
    protected City city;
    protected Country country;
    protected int dataLevel;
    protected HotelType hotelType;
    protected long id;
    @XmlSchemaType(name = "dateTime")
    protected XMLGregorianCalendar lastModifiedDate;
    protected String name;
    protected Province province;
    @XmlElement(nillable = true)
    protected List<RoomType> roomTypes;
    protected Street street;
    protected String wsAddress;
    protected String wsName;

    public ServiceDescription() {
	}

	public ServiceDescription(String name, String wsAddress, int dataLevel, Date lastModifiedDate, City city) {
		this.name = name;
		this.wsAddress = wsAddress;
		this.dataLevel = dataLevel;
		setLastModifiedDateAsDate(lastModifiedDate);
		this.city = city;
	}

	
	public ServiceDescription(String name, String wsAddress, int dataLevel, Date lastModifiedDate) {
		this.name = name;
		this.wsAddress = wsAddress;
		this.dataLevel = dataLevel;
		setLastModifiedDateAsDate(lastModifiedDate);		
	}
    
    /**
     * Gets the value of the address property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getAddress() {
        return address;
    }

    /**
     * Sets the value of the address property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setAddress(String value) {
        this.address = value;
    }

    /**
     * Gets the value of the city property.
     * 
     * @return
     *     possible object is
     *     {@link City }
     *     
     */
    public City getCity() {
        return city;
    }

    /**
     * Sets the value of the city property.
     * 
     * @param value
     *     allowed object is
     *     {@link City }
     *     
     */
    public void setCity(City value) {
        this.city = value;
    }

    /**
     * Gets the value of the country property.
     * 
     * @return
     *     possible object is
     *     {@link Country }
     *     
     */
    public Country getCountry() {
        return country;
    }

    /**
     * Sets the value of the country property.
     * 
     * @param value
     *     allowed object is
     *     {@link Country }
     *     
     */
    public void setCountry(Country value) {
        this.country = value;
    }

    /**
     * Gets the value of the dataLevel property.
     * 
     */
    public int getDataLevel() {
        return dataLevel;
    }

    /**
     * Sets the value of the dataLevel property.
     * 
     */
    public void setDataLevel(int value) {
        this.dataLevel = value;
    }

    /**
     * Gets the value of the hotelType property.
     * 
     * @return
     *     possible object is
     *     {@link HotelType }
     *     
     */
    public HotelType getHotelType() {
        return hotelType;
    }

    /**
     * Sets the value of the hotelType property.
     * 
     * @param value
     *     allowed object is
     *     {@link HotelType }
     *     
     */
    public void setHotelType(HotelType value) {
        this.hotelType = value;
    }

    /**
     * Gets the value of the id property.
     * 
     */
    public long getId() {
        return id;
    }

    /**
     * Sets the value of the id property.
     * 
     */
    public void setId(long value) {
        this.id = value;
    }

    /**
     * Gets the value of the lastModifiedDate property.
     * 
     * @return
     *     possible object is
     *     {@link XMLGregorianCalendar }
     *     
     */
    public XMLGregorianCalendar getLastModifiedDate() {
        return lastModifiedDate;
    }

    /**
     * Sets the value of the lastModifiedDate property.
     * 
     * @param value
     *     allowed object is
     *     {@link XMLGregorianCalendar }
     *     
     */
    public void setLastModifiedDate(XMLGregorianCalendar value) {
        this.lastModifiedDate = value;
    }

    public Date getLastModifiedDateAsDate() {
    	if (lastModifiedDate == null)
    		return null;
    	return lastModifiedDate.toGregorianCalendar().getTime();
    }
    
    public void setLastModifiedDateAsDate(Date lastModifiedDate) {
   	 	DatatypeFactory df = null;
		try {
			df = DatatypeFactory.newInstance();
		} catch (DatatypeConfigurationException e) {
			e.printStackTrace();
		}
    	 GregorianCalendar gc = new GregorianCalendar();
         gc.setTimeInMillis(lastModifiedDate.getTime());
         this.lastModifiedDate = df.newXMLGregorianCalendar(gc);
    }
    
    /**
     * Gets the value of the name property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getName() {
        return name;
    }

    /**
     * Sets the value of the name property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setName(String value) {
        this.name = value;
    }

    /**
     * Gets the value of the province property.
     * 
     * @return
     *     possible object is
     *     {@link Province }
     *     
     */
    public Province getProvince() {
        return province;
    }

    /**
     * Sets the value of the province property.
     * 
     * @param value
     *     allowed object is
     *     {@link Province }
     *     
     */
    public void setProvince(Province value) {
        this.province = value;
    }

    /**
     * Gets the value of the roomTypes property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the roomTypes property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getRoomTypes().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link RoomType }
     * 
     * 
     */
    public List<RoomType> getRoomTypes() {
        if (roomTypes == null) {
            roomTypes = new ArrayList<RoomType>();
        }
        return this.roomTypes;
    }

    /**
     * Gets the value of the street property.
     * 
     * @return
     *     possible object is
     *     {@link Street }
     *     
     */
    public Street getStreet() {
        return street;
    }

    /**
     * Sets the value of the street property.
     * 
     * @param value
     *     allowed object is
     *     {@link Street }
     *     
     */
    public void setStreet(Street value) {
        this.street = value;
    }

    /**
     * Gets the value of the wsAddress property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getWsAddress() {
        return wsAddress;
    }

    /**
     * Sets the value of the wsAddress property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setWsAddress(String value) {
        this.wsAddress = value;
    }

    /**
     * Gets the value of the wsName property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getWsName() {
        return wsName;
    }

    /**
     * Sets the value of the wsName property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setWsName(String value) {
        this.wsName = value;
    }
    
//    @Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((wsAddress == null) ? 0 : wsAddress.hashCode());
		return result;
	}

//	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ServiceDescription other = (ServiceDescription) obj;
		if (wsAddress == null) {
			if (other.wsAddress != null)
				return false;
		} else if (!wsAddress.equals(other.wsAddress))
			return false;
		return true;
	}

//	@Override
	public int compareTo(ServiceDescription o) {
		if (!(o instanceof ServiceDescription))
				throw new ClassCastException();
		
		return o.wsAddress.compareTo(wsAddress);
	}
	
//	@Override
	public String toString() {
		return wsAddress;
	}

}
